// src/upload/multer.config.ts
import { diskStorage } from 'multer';
import { join } from 'path';
import { v4 as uuidv4 } from 'uuid'; // 可选：用于生成唯一文件名

export const multerOptions = {
  storage: diskStorage({
    destination: join(__dirname, '..', '..', 'uploads', 'temp'), // 临时目录
    filename: (req, file, cb) => {
      // 保留原始扩展名
      const ext = file.originalname.split('.').pop();
      const filename = `${uuidv4()}.${ext}`;
      cb(null, filename);
    },
  }),
};
